Phase B: Household sampling, structural edges, identity clustering#64
Merged
Conversation
…tering (Phase B) B1: Household-based sampling - Add HouseholdType enum, Dependent model, scope field on AttributeSpec - New households.py with Census-derived correlation tables for assortative mating - Rewrite sample_population to produce household units with correlated partner demographics - Add households table to study_db and save/get methods - CLI reports household type distribution B2: Structural edge generation - Add structural/context fields to Edge model - Generate deterministic edges: partner, household, coworker, neighbor, congregation, school_parent - Structural edges protected from calibration pruning and rewiring - Add degree_distribution_target and power_law_exponent to NetworkConfig B3: Identity clustering + conformity - Add identity_clustering_attributes and boost to NetworkConfig - Boost similarity for agents sharing identity-relevant attributes - Add STANDARD_PERSONALITY_ATTRIBUTES constant (includes conformity) All 181 tests pass (39 new + 142 existing, zero regressions).
… household Phase A's generate_name() was only called in _sample_single_agent. Partner agents from _sample_partner_agent now also get first names, and partners share the primary adult's last name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sample_populationproduces household units with correlated partner demographics (age gap, assortative mating on education/religion/politics, intermarriage rates). NPC dependents generated.householdstable in study DB.conformityadded as standard personality attribute.generate_name().Files changed
extropy/core/models/population.py—HouseholdType,Dependent,scopeonAttributeSpecextropy/core/models/network.py—structural,contextonEdgeextropy/population/sampler/households.py— Census correlation tables + sampling helpersextropy/population/sampler/core.py— Household-awaresample_population(backward compat)extropy/population/network/generator.py—_generate_structural_edges(), identity clustering boostextropy/population/network/config.py—degree_distribution_target,identity_clustering_*extropy/storage/study_db.py—householdstableextropy/cli/commands/sample.py— Household stats in reportTest plan
test_household_sampling.py(24 tests) — models, helpers, household sampling, backward compat, correlated demographicstest_structural_edges.py(15 tests) — edge generation, model enhancements, config🤖 Generated with Claude Code